/*
** ADOBE SYSTEMS INCORPORATED
** Copyright 2012 Adobe Systems Incorporated
** All Rights Reserved.
**
** NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the
** terms of the Adobe license agreement accompanying it.  If you have received this file from a
** source other than Adobe, then your use, modification, or distribution of it requires the prior
** written permission of Adobe.
*/
#include "intarraylib.h"

int sumArray(int* buffer, int bufferSize){
	int i;
	int sum = 0;

	for(i = 0; i < bufferSize; i++){
		sum += buffer[i];
	}

	return sum;
}

int dotProductArray(int* buffer, int bufferSize){
	int i;
	int product = 1;

	for(i = 0; i < bufferSize; i++){
		product *= buffer[i];
	}

	return product;
}

IntArray reverseArray(int* buffer, int bufferSize){
	int i = 0;
	int j = bufferSize - 1;

	while (i < j){
		int temp = buffer[i];
		buffer[i] = buffer[j];
		buffer[j] = temp;

		i++;
		j--;
	}
	
	IntArray r = {buffer, bufferSize};
	
	return r;
}

IntArray incrementArray(int* buffer, int bufferSize){
	int i;
	
	for (i = 0; i < bufferSize; i++){
		buffer[i]++;
	}

	IntArray r = {buffer, bufferSize};
	
	return r;
}
